package com.web.dao;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.web.entity.ProfitConfig;

/**
 * @author FDjavaone
 */
public class ProfitConfigSqlProvider {

    public String insertSelective(ProfitConfig record) {
        BEGIN();
        INSERT_INTO("t_profit_config");
        
        if (record.getCompanyProfitPool() != null) {
            VALUES("company_profit_pool", "#{companyProfitPool,jdbcType=DECIMAL}");
        }
        
        if (record.getCompanyFundPool() != null) {
            VALUES("company_fund_pool", "#{companyFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getMarketFundPool() != null) {
            VALUES("market_fund_pool", "#{marketFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getBonusPool() != null) {
            VALUES("bonus_pool", "#{bonusPool,jdbcType=DECIMAL}");
        }
        
        if (record.getConsumeProfit() != null) {
            VALUES("consume_profit", "#{consumeProfit,jdbcType=DECIMAL}");
        }
        
        if (record.getMerchantProfit() != null) {
            VALUES("merchant_profit", "#{merchantProfit,jdbcType=DECIMAL}");
        }
        
        if (record.getAgentProvince() != null) {
            VALUES("agent_province", "#{agentProvince,jdbcType=DECIMAL}");
        }
        
        if (record.getAgentCity() != null) {
            VALUES("agent_city", "#{agentCity,jdbcType=DECIMAL}");
        }
        
        if (record.getAgentRegion() != null) {
            VALUES("agent_region", "#{agentRegion,jdbcType=DECIMAL}");
        }
        
        if (record.getCorePoints() != null) {
            VALUES("core_points", "#{corePoints,jdbcType=DECIMAL}");
        }
        
        if (record.getFission() != null) {
            VALUES("fission", "#{fission,jdbcType=DECIMAL}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(ProfitConfig record) {
        BEGIN();
        UPDATE("t_profit_config");
        
        if (record.getCompanyProfitPool() != null) {
            SET("company_profit_pool = #{companyProfitPool,jdbcType=DECIMAL}");
        }
        
        if (record.getCompanyFundPool() != null) {
            SET("company_fund_pool = #{companyFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getMarketFundPool() != null) {
            SET("market_fund_pool = #{marketFundPool,jdbcType=DECIMAL}");
        }
        
        if (record.getBonusPool() != null) {
            SET("bonus_pool = #{bonusPool,jdbcType=DECIMAL}");
        }
        
        if (record.getConsumeProfit() != null) {
            SET("consume_profit = #{consumeProfit,jdbcType=DECIMAL}");
        }
        
        if (record.getMerchantProfit() != null) {
            SET("merchant_profit = #{merchantProfit,jdbcType=DECIMAL}");
        }
        
        if (record.getAgentProvince() != null) {
            SET("agent_province = #{agentProvince,jdbcType=DECIMAL}");
        }
        
        if (record.getAgentCity() != null) {
            SET("agent_city = #{agentCity,jdbcType=DECIMAL}");
        }
        
        if (record.getAgentRegion() != null) {
            SET("agent_region = #{agentRegion,jdbcType=DECIMAL}");
        }
        
        if (record.getCorePoints() != null) {
            SET("core_points = #{corePoints,jdbcType=DECIMAL}");
        }
        
        if (record.getFission() != null) {
            SET("fission = #{fission,jdbcType=DECIMAL}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=BIGINT}");
        
        return SQL();
    }
}